var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  ZhenRongDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.zhujiaoJson = {}),
        (e.zr_kangJson = {}),
        (e.fujiang_skills = []),
        (e.fujiang_skills_sel = []),
        (e.kang_isOk = !1),
        (e.prop_isOk = !1),
        e.tab_zr.on(Laya.Event.CLICK, e, e.onTabClick),
        (e.radio_zr_group.selectHandler = new Handler(
          e,
          e.onRadioSelectHandler
        )),
        e.btn_set_zr.on(Laya.Event.CLICK, e, e.confirmZhenRongAction),
        (e.list_zr_zuoji.selectEnable = !0),
        (e.list_zr_zuoji.renderHandler = new Handler(
          e,
          e.onZuoJiRenderHandler
        )),
        e.list_zr_zuoji.on(Laya.Event.CLICK, e, e.onZuoJiListAction),
        (e.list_zr_fujiang.selectEnable = !0),
        e.list_zr_fujiang.on(Laya.Event.CLICK, e, e.onFiJiangListAction),
        e.box_jineng_item1.on(Laya.Event.CLICK, e, e.onJiNengItemAction),
        e.box_jineng_item2.on(Laya.Event.CLICK, e, e.onJiNengItemAction),
        e.box_jineng_item3.on(Laya.Event.CLICK, e, e.onJiNengItemAction),
        e.box_jineng_item4.on(Laya.Event.CLICK, e, e.onJiNengItemAction),
        e.text_kangwu.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kangxuan.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kangfeng.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kangluan.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kangwei.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kang_lei.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kang_feng.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kang_huo.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_kang_du.on(Laya.Event.BLUR, e, e.onTextInputEnterFn),
        e.text_pro_tizhi.on(Laya.Event.BLUR, e, e.onProTextInputEnterFn),
        e.text_pro_zhili.on(Laya.Event.BLUR, e, e.onProTextInputEnterFn),
        e.text_pro_liliang.on(Laya.Event.BLUR, e, e.onProTextInputEnterFn),
        e.text_pro_minjie.on(Laya.Event.BLUR, e, e.onProTextInputEnterFn),
        WebSocketService.addListener({
          caller: e,
          code: 5297,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5292,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5302,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5300,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5301,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5303,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5306,
          method: e.onLoadHomePageData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5294,
          method: e.onRequestConfigData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5290,
          method: e.onRequestConfigData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5293,
          method: e.onRequestConfigData,
        }),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showZhenRongDialog = function (t) {
        return (
          null == this.zrDialog &&
            ((this.zrDialog = new e()), (this.zrDialog.zOrder = 1e3)),
          (this.zrDialog.kang_sum = 200),
          this.zrDialog.popup(),
          (this.zrDialog.jsonDict = t),
          this.zrDialog.inits(),
          this.zrDialog
        );
      }),
      (e.prototype.inits = function () {
        (this.zhujiaoJson = {}),
          (this.zr_kangJson = {}),
          (this.sel_fujiang_obj = {}),
          (this.isZhuJiangSetting = !0),
          (this.tab_zr.selectedIndex = 0),
          (this.lab_zr_zhujiang.text = Global.roleName),
          (this.radio_zr_group.selectedIndex = 0),
          (this.label_zr_zhujiang.visible = !0),
          (this.label_zr_fujiang.visible = !1),
          (this.label_zr_zuoji.visible = !1),
          (this.label_fujiang_jineng_view.visible = !1),
          this.onTextInputEnterFn(),
          this.onProTextInputEnterFn(),
          this.loadInitData(null),
          (this.zhujiaoJson.roleId = Global.roleId),
          (this.zhujiaoJson.roleType = "1"),
          (this.zhujiaoJson.groupId = this.jsonDict.groupId),
          WebSocketService.send({
            c: 5302,
            d: { groupId: this.jsonDict.groupId },
          });
      }),
      (e.prototype.confirmZhenRongAction = function () {
        this.kang_isOk && this.prop_isOk
          ? WebSocketService.send({ c: 5290, d: this.zhujiaoJson })
          : ToastView.toastView("请先配置完毕抗性和属性");
      }),
      (e.prototype.onSureZhengRongAction = function () {
        this.isZhuJiangSetting
          ? ((this.zr_kangJson.groupId = this.jsonDict.groupId),
            WebSocketService.send({ c: 5294, d: this.zr_kangJson }))
          : ((this.zr_kangJson.cortegeId = this.sel_fujiang_obj.id),
            WebSocketService.send({ c: 5303, d: this.zr_kangJson }));
      }),
      (e.prototype.fujiangChuZhanAction = function () {
        for (var t = 0, e = 0, i = 0; i < this.fujiang_skills_sel.length; i++) {
          var n = this.fujiang_skills_sel[i];
          0 == i ? (t = n.skillid) : 1 == i && (e = n.skillid);
        }
        WebSocketService.send({
          c: 5301,
          d: {
            roleId: Global.roleId,
            ap: this.text_pro_liliang.text,
            mp: this.text_pro_zhili.text,
            hp: this.text_pro_tizhi.text,
            sp: this.text_pro_minjie.text,
            npcId: this.sel_npc_id,
            groupId: this.jsonDict.groupId,
            roleType: this.zhujiaoJson.roleType,
            skill1: t,
            skill2: e,
            cortegeId: this.sel_fujiang_obj.id,
          },
        });
      }),
      (e.prototype.onTextInputEnterFn = function () {
        (this.zr_kangJson.k_wl = Utils.getNumberFormTextInput(
          this.text_kangwu
        )),
          (this.zr_kangJson.k_xi = Utils.getNumberFormTextInput(
            this.text_kangxuan
          )),
          (this.zr_kangJson.k_ll = Utils.getNumberFormTextInput(
            this.text_kang_lei
          )),
          (this.zr_kangJson.k_fa = Utils.getNumberFormTextInput(
            this.text_kang_feng
          )),
          (this.zr_kangJson.k_yh = Utils.getNumberFormTextInput(
            this.text_kang_huo
          )),
          (this.zr_kangJson.k_du = Utils.getNumberFormTextInput(
            this.text_kang_du
          )),
          (this.zr_kangJson.k_wei = Utils.getNumberFormTextInput(
            this.text_kangwei
          )),
          (this.zr_kangJson.k_feng = Utils.getNumberFormTextInput(
            this.text_kangfeng
          )),
          (this.zr_kangJson.k_luan = Utils.getNumberFormTextInput(
            this.text_kangluan
          ));
        var t = this.kang_sum,
          e = 0;
        for (var i in this.zr_kangJson)
          if (this.zr_kangJson.hasOwnProperty(i)) {
            e += this.zr_kangJson[i];
          }
        (this.kang_isOk = e >= t),
          (this.label_zr_kang_dianshu.text = e + " / " + t),
          e > t && ToastView.toastView("分配的抗性点数超过最大值");
      }),
      (e.prototype.onProTextInputEnterFn = function () {
        (this.zhujiaoJson.hp = Utils.getNumberFormTextInput(
          this.text_pro_tizhi
        )),
          (this.zhujiaoJson.mp = Utils.getNumberFormTextInput(
            this.text_pro_zhili
          )),
          (this.zhujiaoJson.ap = Utils.getNumberFormTextInput(
            this.text_pro_liliang
          )),
          (this.zhujiaoJson.sp = Utils.getNumberFormTextInput(
            this.text_pro_minjie
          ));
        var t = 0;
        (t =
          this.zhujiaoJson.hp +
          this.zhujiaoJson.mp +
          this.zhujiaoJson.ap +
          this.zhujiaoJson.sp),
          (this.prop_isOk = t >= 480),
          (this.label_zr_pro_dianshu.text = t + " / 480"),
          t >= 480 && ToastView.toastView("分配的属性超过最大值");
      }),
      (e.prototype.onRadioSelectHandler = function (t) {
        this.isZhuJiangSetting
          ? 0 == t
            ? ((this.zhujiaoJson.roleType = 1),
              this.configZhuJiangJiNengView(Dictionary.wushiSkillDesc))
            : 1 == t
            ? ((this.zhujiaoJson.roleType = 2),
              this.configZhuJiangJiNengView(Dictionary.wenrenSkillDesc))
            : 2 == t &&
              ((this.zhujiaoJson.roleType = 3),
              this.configZhuJiangJiNengView(Dictionary.yishiSkillDesc))
          : (0 == t
              ? (this.zhujiaoJson.roleType = 1)
              : 1 == t
              ? (this.zhujiaoJson.roleType = 2)
              : 2 == t && (this.zhujiaoJson.roleType = 3),
            WebSocketService.send({
              c: 5300,
              d: {
                npcId: this.sel_npc_id,
                roleType: this.zhujiaoJson.roleType,
              },
            }));
      }),
      (e.prototype.onLoadHomePageData = function (t) {
        if (5292 == t.act_id) {
          (n = t.data).length > 0 && (this.list_zr_zuoji.visible = !0);
          for (var e = [], i = 0; i < n.length; i++) {
            (o = {
              item_zr_zuoqi_label: { text: (s = n[i]).n },
              hid: s.hid,
              s: s.s,
              t: s.t,
            }),
              e.push(o);
          }
          this.list_zr_zuoji.dataSource = e;
        } else if (5297 == t.act_id) {
          var n = t.data;
          n.length > 0 && (this.list_zr_fujiang.visible = !0);
          for (var o, e = [], i = 0; i < n.length; i++) {
            var s = n[i];
            (o = {
              item_fujiang: { text: s.lvl + "级 " + s.name },
              id: s.id,
              t: s.t,
              ap: s.ap,
              mp: s.mp,
              hp: s.hp,
              sp: s.sp,
              npcId: s.npc_id,
              roleType: s.roletype,
              skill1: s.skill1,
              skill2: s.skill2,
              cortegeId: s.npc_id,
              name: s.name,
            }),
              e.push(o);
          }
          this.list_zr_fujiang.dataSource = e;
        } else
          5302 == t.act_id
            ? (ToastView.toastView(t.msg), t.data && this.loadInitData(t.data))
            : 5300 == t.act_id
            ? this.configFuJiangJiNengView(t.data)
            : 5301 == t.act_id
            ? ToastView.toastView(t.msg)
            : 5303 == t.act_id
            ? (ToastView.toastView(t.msg),
              0 == t.code && this.fujiangChuZhanAction())
            : 5306 == t.act_id &&
              (ToastView.toastView(t.msg), t.data && this.loadInitData(t.data));
      }),
      (e.prototype.configZhuJiangJiNengView = function (t) {
        for (var e = 0; e < t.length; e++) {
          var i = t[e];
          0 == e
            ? (this.label_jineng_1.text = i.title)
            : 1 == e
            ? (this.label_jineng_2.text = i.title)
            : 2 == e
            ? (this.label_jineng_3.text = i.title)
            : 3 == e && (this.label_jineng_4.text = i.title);
        }
      }),
      (e.prototype.configFuJiangJiNengView = function (t) {
        for (var e, i, n, o, s = 0; s < t.length; s++) {
          var a = t[s];
          0 == s
            ? ((this.box_jineng_item1._childs[1].text = a.name),
              (e = a.skillid))
            : 1 == s
            ? ((this.box_jineng_item2._childs[1].text = a.name),
              (i = a.skillid))
            : 2 == s
            ? ((this.box_jineng_item3._childs[1].text = a.name),
              (n = a.skillid))
            : 3 == s &&
              ((this.box_jineng_item4._childs[1].text = a.name),
              (o = a.skillid));
        }
        this.fujiang_skills = [
          { obj: this.box_jineng_item1, selected: !1, skillid: e },
          { obj: this.box_jineng_item2, selected: !1, skillid: i },
          { obj: this.box_jineng_item3, selected: !1, skillid: n },
          { obj: this.box_jineng_item4, selected: !1, skillid: o },
        ];
      }),
      (e.prototype.onJiNengItemAction = function (t) {
        var e = t.target.name,
          i = 0,
          n = null;
        "item1" == e
          ? ((i = 0), (n = this.box_jineng_item1))
          : "item2" == e
          ? ((i = 1), (n = this.box_jineng_item2))
          : "item3" == e
          ? ((i = 2), (n = this.box_jineng_item3))
          : "item4" == e && ((i = 3), (n = this.box_jineng_item4));
        var o = 0;
        this.fujiang_skills.forEach(function (t) {
          t.selected && o++;
        }),
          o >= 2 && !this.fujiang_skills[i].selected
            ? ToastView.toastView("一次最多只能选择两个技能")
            : ((this.fujiang_skills[i].selected =
                !this.fujiang_skills[i].selected),
              this.fujiang_skills[i].selected
                ? (this.getButton(n).skin = "comp/Home/btn_icon_select.png")
                : (this.getButton(n).skin = "comp/Home/btn_icon_noselect.png"),
              this.fujiang_skills_sel.push(this.fujiang_skills[i]));
      }),
      (e.prototype.getButton = function (t) {
        return t._childs[0];
      }),
      (e.prototype.loadInitData = function (t) {
        t
          ? ((this.text_kangwu.text = t.k_wl),
            (this.text_kangxuan.text = t.k_xi),
            (this.text_kangfeng.text = t.k_feng),
            (this.text_kangluan.text = t.k_luan),
            (this.text_kangwei.text = t.k_wei),
            (this.text_kang_lei.text = t.k_ll),
            (this.text_kang_feng.text = t.k_fa),
            (this.text_kang_huo.text = t.k_yh),
            (this.text_kang_du.text = t.k_du),
            this.onTextInputEnterFn(),
            (this.text_pro_tizhi.text = t.hp_p),
            (this.text_pro_zhili.text = t.mp_p),
            (this.text_pro_liliang.text = t.ap_p),
            (this.text_pro_minjie.text = t.sp_p),
            this.onProTextInputEnterFn(),
            1 == t.roleType
              ? (this.radio_zr_group.selectedIndex = 0)
              : 2 == t.roleType
              ? (this.radio_zr_group.selectedIndex = 1)
              : 3 == t.roleType && (this.radio_zr_group.selectedIndex = 2),
            this.onRadioSelectHandler(this.radio_zr_group.selectedIndex),
            console.log("data.roleType:" + t.roleType))
          : ((this.text_kangwu.text = "0"),
            (this.text_kangxuan.text = "0"),
            (this.text_kangfeng.text = "0"),
            (this.text_kangluan.text = "0"),
            (this.text_kangwei.text = "0"),
            (this.text_kang_lei.text = "0"),
            (this.text_kang_feng.text = "0"),
            (this.text_kang_huo.text = "0"),
            (this.text_kang_du.text = "0"),
            (this.text_pro_tizhi.text = "0"),
            (this.text_pro_zhili.text = "0"),
            (this.text_pro_liliang.text = "0"),
            (this.text_pro_minjie.text = "0"),
            (this.label_zr_kang_dianshu.text = "0/200"),
            (this.label_zr_pro_dianshu.text = "480/960"));
      }),
      (e.prototype.onZuoJiRenderHandler = function (t, e) {
        var i = t.getChildByName("item_zr_zuoji");
        1 == t.dataSource.s
          ? ((i.label = "已骑乘"), (i.skin = "comp/commonpic/btn_fayoubao.png"))
          : ((i.label = "骑乘"),
            (i.skin = "comp/commonpic/btn_box_silver.png"));
      }),
      (e.prototype.onZuoJiListAction = function (t) {
        if ("" != t.target.name) {
          var e = this.list_zr_zuoji.selectedItem;
          WebSocketService.send({
            c: 5293,
            d: {
              groupId: this.jsonDict.groupId,
              horseId: e.hid,
              horseType: e.t,
            },
          });
        }
      }),
      (e.prototype.onTabClick = function (t) {
        (this.list_zr_zuoji.visible = !1),
          "item0" == t.target.name
            ? ((this.label_zr_zhujiang.visible = !0),
              (this.label_zr_fujiang.visible = !1),
              (this.label_zr_zuoji.visible = !1),
              (this.isZhuJiangSetting = !0),
              (this.kang_sum = 150),
              (this.btn_set_zr.label = "确定"),
              this.inits(),
              (this.label_zhujiang_jineng_view.visible = !0),
              (this.label_fujiang_jineng_view.visible = !1))
            : "item1" == t.target.name
            ? ((this.label_zr_zhujiang.visible = !1),
              (this.label_zr_fujiang.visible = !0),
              (this.label_zr_zuoji.visible = !1),
              WebSocketService.send({ c: 5297, d: { roleId: Global.roleId } }),
              (this.isZhuJiangSetting = !1),
              (this.kang_sum = 200),
              (this.btn_set_zr.label = "出战"))
            : "item2" == t.target.name &&
              ((this.label_zr_zhujiang.visible = !1),
              (this.label_zr_fujiang.visible = !1),
              (this.label_zr_zuoji.visible = !0),
              WebSocketService.send({
                c: 5292,
                d: { roleId: Global.roleId, groupId: this.jsonDict.groupId },
              }));
      }),
      (e.prototype.onRequestConfigData = function (t) {
        ToastView.toastView(t.msg),
          5294 == t.act_id
            ? 0 == t.code &&
              ((this.zhujiaoJson.roleId = Global.roleId),
              (this.zhujiaoJson.groupId = this.jsonDict.groupId),
              this.close())
            : 5290 == t.act_id
            ? this.onSureZhengRongAction()
            : 5293 == t.act_id &&
              WebSocketService.send({
                c: 5292,
                d: { roleId: Global.roleId, groupId: this.jsonDict.groupId },
              });
      }),
      (e.prototype.onFiJiangListAction = function (t) {
        if ("" != t.target.name) {
          var e = this.list_zr_fujiang.selectedItem;
          "item_peizhi_fujiang" == t.target.name &&
            ((this.label_zr_zhujiang.visible = !0),
            (this.label_zr_fujiang.visible = !1),
            WebSocketService.send({ c: 5297, d: { roleId: e.npcId } }),
            WebSocketService.send({ c: 5306, d: { cortegeId: e.id } }),
            (this.label_zhujiang_jineng_view.visible = !1),
            (this.label_fujiang_jineng_view.visible = !0),
            WebSocketService.send({
              c: 5300,
              d: { npcId: e.npcId, roleType: this.zhujiaoJson.roleType },
            }),
            (this.sel_npc_id = e.npcId),
            (this.sel_fujiang_obj = e),
            this.initFuJiangPageView(e),
            this.loadInitData(void 0));
        }
      }),
      (e.prototype.initFuJiangPageView = function (t) {
        this.lab_zr_zhujiang.text = t.name;
      }),
      e
    );
  })(ui.battlefield.ZhenRongDialogUI);
